package fr.efrei.tradesys.struts.actions.admin;

import java.util.Collections;
import java.util.Comparator;
import java.util.List;

import org.apache.commons.beanutils.BeanComparator;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.opensymphony.xwork2.ActionSupport;

import fr.efrei.tradesys.hibernate.beans.Currency;
import fr.efrei.tradesys.hibernate.factory.DaoFactory;

public class AddUserBeginAction extends ActionSupport
{

	/**
	 * 
	 */
	private static final long	serialVersionUID	= 1L;
	private static Log				LOGGER						= LogFactory
																									.getLog(AddUserBeginAction.class);
	private List<Currency>		currencies;

	@SuppressWarnings("unchecked")
	public String execute() throws Exception
	{
		LOGGER.info("Execution of " + this.getClass().getName());
		currencies = DaoFactory.getInstance().getCurrencyDao().getAllCurrency();
		Comparator<Currency> currencyCompName = new BeanComparator("name");
		Collections.sort(currencies, currencyCompName);
		return SUCCESS;
	}

	public List<Currency> getCurrencies()
	{
		return currencies;
	}

	public void setCurrencies(List<Currency> currencies)
	{
		this.currencies = currencies;
	}

}
